<!--
 * @description  :统一待办情报入口
 * @descriptionDetail:统一待办情报入口
 * @copyright    : 浙江烟草
 * @author       : dw
 * @create       : 2022-10-09 22:21:21
-->
<template>
  <view class="page" style="padding: 0;background-color: white;"></view>
</template>

<script>
import inteligenceService from '@/service/intelligence/intelligence.service.js';
export default {
  onLoad(opt) {
    this.prvParam = this.getRouteParam() || {};
    this.init();
  },
  data() {
    return {
      prvParam: {},
      intentEnum: {
        'clueTransfer': '/pages/intelligence/intelligenceFilesAdd/registration?from=2', // 情报线索登记表   不走流程了
        'qbDocReportRecord': '/pages/intelligence/intelligenceFilesAdd/clueReportInfo?fromType=todo&delt=1', // 情报-举报记录表
      },
    };
  },
  methods: {
    init() {
      if (this.prvParam.bizCode == 'clueTransfer') {
        if (!this.prvParam.bizUuid) {
          this.$modal.alert('业务主键缺失', () => {
            this.error();
          });
          return;
        }
        this.$modal.showLoading('加载中...');
        inteligenceService.getByUuid({
          uuid: this.prvParam.bizUuid,
        }).then(res => {
          this.$modal.hideLoading();
          if (res.success) {
            this.setRouteParam(res.bean);
            this.$u.route({
              url: this.intentEnum[this.prvParam.bizCode] + "&taskId=" + this.prvParam
                .taskId,
              type: "redirect",
            });
          } else {
            this.$modal.alert(res.msg, () => {
              this.error();
            });
          }
        }).catch(e => {
          this.$modal.hideLoading();
          this.$modal.alert("请求异常:" + e, () => {
            this.error();
          });
        });
      }
      if (!this.$u.test.isEmpty(this.intentEnum[this.prvParam.gfCode])) {
        this.setRouteParam({
          bizUuid: this.prvParam.bizUuid,
          uuid: this.prvParam.bizUuid,
          taskId: this.prvParam.taskId,
          bizCode: this.prvParam.bizCode,
        });
        this.$u.route({
          url: this.intentEnum[this.prvParam.gfCode],
          type: "redirect",
        });
      } else {
        this.$modal.alert('该待办钉钉尚未支持,请在PC端处理', () => {
          this.error();
        });
      }
    },
    error() {
      uni.navigateBack();
    },
  },
}
</script>

<style scoped lang="scss">
</style>
